package com.zero.controller;

import com.zero.entity.Condition;
import com.zero.entity.Loan;
import com.zero.service.LoanService;
import com.zero.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/loan")
public class LoanController {
    
    @Autowired
    private LoanService loanService;

    @PostMapping("/list")
    public Result loanList(@RequestBody Condition condition, HttpServletRequest request){
        return loanService.select(condition, request);
    }

    @PostMapping("addLoan")
    public Result addLoan(@RequestBody Loan loan, HttpServletRequest request){
        return loanService.add(loan, request);
    }

    @GetMapping("/deleteLoan")
    public Result deleteLoan(@RequestParam("ids") String ids){
        return loanService.delete(ids);
    }

    @PostMapping("/updateLoan")
    public Result updateLoan(@RequestBody Loan loan, HttpServletRequest request){
        return loanService.update(loan, request);
    }

    @PostMapping("/retrieveLoan")
    public Result retrieveLoan(@RequestBody Map map, HttpServletRequest request){
        return loanService.retrieveLoan(map, request);
    }
}
